<?php
// 本类由系统自动生成，仅供测试用途
namespace Xcx\Controller;
use Think\Controller;
use Xcx\Model\GoodsModel;
use Xcx\Model\VideoDanmuModel;
use Xcx\Model\VideoModel;

class IndexController extends CommonController {

    public function test () {
        $this->display();
    }

    /**
     * 主页
     */
    public function index(){
        $Goods = new GoodsModel();
        $list = $Goods->getGoodsList();

        $this->ajaxReturn($list);
    }

    /**
     * 获取首页视频
     */
    public function getVideo()
    {
        $Video = new VideoModel();
        $video = $Video->getVideo();

        $this->ajaxReturn($video);
    }

    /**
     * 商品详情
     */

    public function getGoodsDetails()
    {
        $gid = I('gid');
        $Goods = new GoodsModel();
        $data = $Goods->getGoodsDetails($gid);
        $this->ajaxReturn($data);
    }

    /**
     * 添加视频弹幕
     */
    public function addDanmu()
    {
        $this->checkLogin();

        $vid = I('vid','');
        $content = I('content','');
        $times = I('times','');
        if ($vid == '' || $content == '' || $times == '') {
            $this->ajaxReturn(true);
        }
        $VideoDanmu = new VideoDanmuModel();
        $VideoDanmu->addDanmu($vid, $content, $times);
        $arr['code'] = 0;
        $this->ajaxReturn($arr);
    }
}